package com.project.study.farming.common.jump;

import com.project.study.farming.common.utils.CommonUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * 跳转页面控制器
 */
@Controller
public class PagesController {

    @GetMapping("index")
    public String index(){
        return "index";
    }

    @GetMapping("reg.html")
    public String reg(){
        return "reg";
    }

    @GetMapping("about.html")
    public ModelAndView about(){
        return this.getModelAndView("about");
    }

    @GetMapping("blog.html")
    public ModelAndView blog(){
        return this.getModelAndView("blog");
    }

    @GetMapping("contact.html")
    public ModelAndView contact(){
        return this.getModelAndView("contact");
    }

    @GetMapping("events.html")
    public ModelAndView events(){
        return this.getModelAndView("events");
    }

    @GetMapping("gallery.html")
    public ModelAndView gallery(){
        return this.getModelAndView("gallery");
    }

    @GetMapping("services.html")
    public ModelAndView services(){
        return this.getModelAndView("services");
    }

    @GetMapping("glabout.html")
    public ModelAndView glabout(){
        return this.getModelAndView("glabout");
    }

    private ModelAndView getModelAndView(String viewName){
        ModelAndView view = new ModelAndView();
        view.setViewName(viewName);
        view.addObject("user", CommonUtil.getUser());
        return view;
    }
}
